local CommonOHOH = _G.CommonOHOH;
local M = CommonOHOH.class.new(script, CommonOHOH.files.BaseComponent());



function M.new(self,...)
	return M(self,...);
end;

function M.ctor(self, parent)
	M.super.ctor(self, parent);
    

    
    -- --掉落肉
     self.meatCount=self.parent.cfg.meat
     self.drop=self.parent.cfg.drop
     self.Battle=self.parent.Battle
    -- self.SizeId=self.parent:GetSizeId()

    self.parent.DieEvent:Connect(function(attacker)
        -- 战斗中的所有玩家都活得奖励
        for _,player in pairs(self.Battle:GetAllPlayerList()) do
            self:SaveDrop(player)
        end
    end)

   
end;

function M.SaveDrop(self,player)

    local  DataStore=player:GetComponent(_G.ServerOHOH.load.Server_PlayerDataComponent())
    DataStore:GetData("statistics").kill=DataStore:GetData("statistics").kill+1

    player.UserDataEvent:Action("statistics")
    player.OnboardingFunnelEvent:Action("kill_1")



    local  itemCtrl=player:GetComponent(_G.ServerOHOH.load.Server_ItemCtrl())
    local  playerCtrl=player:GetComponent(_G.CommonOHOH.load.Common_PlayerToolCtrl())

    local data=playerCtrl:GetDrop({base_meat=self.meatCount})


    if  self.drop then
        local d1=playerCtrl:GetDrop(self.drop)
        --合并掉落数据
        for k,v in pairs(d1) do
            if not  data[k] then
                data[k]=v
            else
                data[k]=data[k]+v
            end
        end
    end
    itemCtrl:AddItem(data)
end



function M.dtor(self)
	M.super.dtor(self);
end



return M